var socket = io.connect("/");
    exports.order = function (msgName,cb) {
        //将socket加入msgName 的订阅列表
        socket.emit("order", {'msgName': msgName, 'socketID': socket.id});
        socket.on(msgName, function (data) {
            execute_cb(data, cb);
        });
    };

    exports.disorder = function (msgName, cb) {
        //将socket加入msgName 的订阅列表
        socket.emit("disorder", {'msgName': msgName, 'socketID': socket.id});
        socket.on(msgName, function (data) {
            execute_cb(data, cb);
        });
    };

exports.onConnected = function(cb){
    if(socket.connected){
        execute_cb(null,cb);
    }else{
        socket.on('connected', function () {
            //console.log("socket.io connected");
            execute_cb(null,cb);
        });
    }
};

function execute_cb(data, cb) {
    if (cb && typeof cb === 'function') {
        cb(data);
    }
}